#pragma once
#include <stdarg.h>
#include <cstdio>
#include <cstring>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

inline void debugprintf(const wchar_t *format, ...)
{
	va_list ap;
	wchar_t *f = NULL;
	const wchar_t *p = L"%s:%d ";
	size_t plen = wcslen(p);
	va_start(ap, format);
	f = (wchar_t*)malloc((plen + wcslen(format) + 1)*sizeof(wchar_t));
	if (!f) return;
	memcpy(f, p, plen*sizeof(wchar_t));
	memcpy(f + plen*sizeof(wchar_t), format, (wcslen(format) + 1)*sizeof(wchar_t));
	vfwprintf(stderr, f, ap);
	va_end(ap);
	free(f);
}
inline void dummyprintf(const wchar_t *format, ...)
{}

#ifdef DEBUG
#define DEBUGP debugprintf
#else
#define DEBUGP dummyprintf

#endif